<template>
<div>
  <x-input
    type="text"
    v-model="result"
    :label="label"
    style="width: 100%"
    :placeholder="placeholder"
  > </x-input>
  <x-button type="primary" @click.native="sys_click">允许</x-button>
</div>

</template>

<script>
  import wx from 'weixin-js-sdk'
  import $ from 'jquery'
  export default {
    props:{
        label:{
            type:String,
            default: ''
        },
      placeholder:{
          type:String,
          default: ''
        }
    },
    data(){
      return{
        result:""
      }
    },
    methods: {
      sys_click (){
        let that = this;
        wx.ready(function () {
          wx.checkJsApi({
            jsApiList: ['scanQRCode'],
            success: function (res) {

            }
          });
          wx.scanQRCode({
            needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
            scanType: ["qrCode"], // 可以指定扫二维码还是一维码，默认二者都有
            success: function (res) {
             // window.location.href = result;//因为我这边是扫描后有个链接，然后跳转到该页面
              that.result= res.resultStr;
              that.$emit("scanSuccess",that.result);
            }
          });

        });
      }


    }

  }
</script>

